import React from "react";
import { Button, Space } from "antd";
import dictTag from "@/component/Dict-Tag/Dict-Tag";
import { DICT_TYPE } from "@/utils/dict";

/**@description 列表表格字段 */
const getColumns = ({ open = Function, handleDelete = Function, gotoDetail = Function }) => {
    return [
        {
            title: "字典编号",
            key: "dictNo",
            dataIndex: "dictNo",
            width: 80,

        },
        {
            title: "字典名称",
            key: "dictName",
            dataIndex: "dictName",
            width: 120,
        },
        {
            title: "字典类型",
            key: "dictType",
            dataIndex: "dictType",
            width: 200,
        },
        {
            title: "状态",
            key: "status",
            dataIndex: "status",
            width: 80,
            render: (value, record) => dictTag({
                type: DICT_TYPE.COMMON_STATUS,
                value: value
            })
        },
        {
            title: "备注",
            key: "remark",
            dataIndex: "remark",
            width: 100,
        },
        {
            title: "创建时间",
            key: "createDate",
            dataIndex: "createDate",
            width: 150,
            type:"Date"
        },
        {
            title: "操作",
            key: "action",
            fixed: "right",
            dataIndex: "action",
            width: 200,
            render: (text, record) => {
                return (
                    <Space>
                        <Button type="link" onClick={() => open({ type: "update", record: record })}>修改</Button>
                        <Button type="link" onClick={() => {
                            gotoDetail(record.dictType)
                        }}>数据</Button>
                        <Button type="link" danger onClick={() => handleDelete(record.dictNo)}>删除</Button>
                    </Space>
                )
            }
        },
    ];
}

export default getColumns;